﻿using System;

namespace MetalSoda
{
    /// <summary>
    /// Specifies information about which stored procedure needs to start to process messages in this queue.
    /// </summary>
    public class Activation
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="MetalSoda.Activation"/> class.
        /// </summary>
        /// <param name="procedureName">Name of the stored procedure to start to process messages in this queue. This value must be a SQL Server identifier.</param>
        /// <param name="maxReaders"></param>
        public Activation(string procedureName, int maxReaders = 1) 
        {
            if (string.IsNullOrWhiteSpace(procedureName)) { throw new ArgumentException("procedureName"); }
            if (maxReaders < 0) { throw new ArgumentOutOfRangeException("maxReaders"); }
            ProcedureName = procedureName;
        }

        /// <summary>
        /// Gets or sets the flag specifying whether Service Broker starts the stored procedure. 
        /// </summary>
        /// <remarks>
        /// When STATUS = ON, the queue starts the stored procedure specified with PROCEDURE_NAME when the number of procedures currently running is less than MAX_QUEUE_READERS 
        /// and when messages arrive on the queue faster than the stored procedures receive messages. When STATUS = OFF, the queue does not start the stored procedure. 
        /// If this clause is not specified, the default is ON.
        /// </remarks>
        public Status Status { get; set; }

        /// <summary>
        /// Name of the stored procedure to start to process messages in this queue. This value must be a SQL Server identifier.
        /// </summary>
        public readonly string ProcedureName;

    }
}
